function DropMenu(menuID,doc,behaviorUrl){
	//debugger;
	this.doc = doc || document;
	var elMenu = this.doc.all[menuID];
	if( elMenu ){//return alert("Element \""+menuID+"\" already exists.");
		elMenu = elMenu.parentElement.removeChild(elMenu);
		elMenu.id = "";
		try{elMenu.hide();}catch(e){top.status = e.description;}
	}
	this.imageStyle = "vertical-align:middle;margin-top:3px;margin-bottom:3px";
	this.menuID = menuID;
	var xmlMenu = new ActiveXObject("Microsoft.XMLDOM");
	this.dropMenu = addElement(xmlMenu,"WM:DROPMENU");
	this.dropMenu.setAttribute("ID",menuID);
	//dropMenu.setAttribute("onserviceavailable","alert('Here.')");
	//this.dropMenu.setAttribute("onreadystatechange",onLoad||"debugger");
	this.dropMenu.setAttribute("style","behavior:url("+(behaviorUrl||"/Include/HTC/dropmenu_d.htc")+");FONT: menu;");
	this.dropMenu.setAttribute("class","nbDropMenu");
	this.dropMenu.setAttribute("HOLDSTYLE","false");
	this.dropMenu.setAttribute("FLY","true");
	this.add = addMenuItem;
	this.menuShow = menuShow;
	this.show = menuShow;
	this.BEHAVIOR = "Dimok 1.0";
	 //class="nbDropMenu" HOLDSTYLE=false menuName="dropMenu"	style="FONT: menu;BACKGROUND-COLOR: white"
	//Locals
	function menuShow(x,y){
		this.doc.body.insertAdjacentHTML("beforeEnd",this.dropMenu.xml);
		var b = this.BEHAVIOR;
		var ce = (event||{}).srcElement;
		this.doc.all[this.menuID].onreadystatechange = function(){
			if( typeof(this.ver) == 'undefined' || this.ver != b )return alert("Wrong version of dropmenu behavior.");
			if(this.readyState=="complete"){
				this.ce = ce;
				this.menuShow(true,x,y);
			}
		}
	}
	function addMenuItem(caption,script,imgPath,type,index){
		if( caption == "-" )return addElement(this.dropMenu,"WM:MENUDIVIDER",undefined,index).parentNode;
		var item = addElement(addElement(this.dropMenu,"WM:MENUROW",undefined,index),"WM:MENUITEM",{type:type||'default'});
		var img = addElement(item,"WM:MENUITEMIMG");
		addElement(img,"IMG",{SRC:imgPath||"/images/blank16x16.gif",style:this.imageStyle});
		addElement(item,"WM:MENUITEMCAPTION").text = caption || "";
		addElement(item,"WM:MENUITEMSCRIPT").text = "var el="+this.menuID+";ce=el.ce;el.hide();"+(script || "");
		return item.parentNode;
	}
	function addElement(parent,name,attributes,index){
		var doc = parent.nodeType == 9 ? parent : parent.ownerDocument;
		var node = doc.createElement(name);
		if( index >= 0 )parent.insertBefore(node,parent.childNodes[index]);
		else parent.appendChild(node);
		var o;
		for( o in attributes )
			node.setAttribute(o,attributes[o]);
		return node;
	}
}
// ***** Static members *****
function CE(child){return getContextElement(child)}
function getContextElement(child){return(getParentDropMenu(child)||{}).ce}
function getParentDropMenu(child){
	while( child.tagName != "DROPMENU" )
		child = child.parentElement;
	return child;
}